import time

def count_bits(n):
    return bin(n).count('1')

def count_bits_2(n):
    return sum( b == '1' for b in bin(n)[2:] )

if __name__ == "__main__":
    n = 12448057941136394342297748548545082997815840357634948550739612798732309975923280685245876950055614362283769710705811182976142803324242407017104841062064840113262840137625582646683068904149296501029754654149991842951570880471230098259905004533869130509989042199261339990315125973721454059973605358766253998615919997174542922163484086066438120268185904663422979603026066685824578356173882166747093246377302371176167843247359636030248569148734824287739046916641832890744168385253915508446422276378715722482359321205673933317512861336054835392844676749610712462818600179225635467147870208L
    
    start = time.time()
    ones = count_bits(n)
    end = time.time()
    print "ones:", ones, "time:", (end-start)*1000, "ms"
    
    start2 = time.time()
    ones_2 = count_bits_2(n)
    end2 = time.time()
    print "ones_2:", ones_2, "time:", (end2-start2)*1000, "ms"
